package com.zhixiang.xaec.action.system;


import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.zhixiang.core.command.QueryFilter;
import com.zhixiang.core.util.String2Array;
import com.zhixiang.core.web.action.BaseAction;
import com.zhixiang.xaec.entity.system.DepUsers;
import com.zhixiang.xaec.service.system.DepUsersService;


@Controller
@Scope("prototype")
public class DepUsersAction extends BaseAction
{

    private static final long serialVersionUID = -2845760127552708298L;

    private DepUsers depUsers;

    @Autowired
    private DepUsersService depUsersService;

    public String save()
    {
        depUsersService.save(depUsers);
        return SUCCESS;
    }

    public String get()
    {
        if (depUsers != null && StringUtils.isNotEmpty(depUsers.getDepUserId().toString()))
        {
            setResult(depUsersService.get(depUsers.getDepUserId()));
        }
        return SUCCESS;
    }

    public String list()
    {
        QueryFilter localQueryFilter = new QueryFilter(getRequest());
        List<DepUsers> list = depUsersService.getAll(localQueryFilter);
        setTotalCounts(localQueryFilter.getPagingBean().getTotalItems());
        setResult(list);
        return SUCCESS;
    }

    public String delete()
    {
        try
        {
            String ids = getRequest().getParameter("ids");
            Long[] l = String2Array.stringToLongArray(ids);
            depUsersService.remove(l);
        }
        catch (Exception e)
        {
            setSuccess(false);
            setMsg("删除失败");
        }

        return SUCCESS;
    }

    public DepUsers getDepUsers()
    {
        return depUsers;
    }

    public void setDepUsers(DepUsers depUsers)
    {
        this.depUsers = depUsers;
    }

   


}
